﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DiamonWebOnline.Models;
using System.Web.Security;

namespace DiamonWebOnline.Controllers
{
    public class AccountController : Controller
    {
        OnlineJewelleryShoppingString db = new OnlineJewelleryShoppingString();
        //
        // GET: /Account/
        //private void MigrateShoppingCart(string email)
        //{
        //    // Associate shopping cart items with logged-in user
        //    var cart = ShoppingCart.GetCart(this.HttpContext);

        //    cart.MigrateCart(email);
        //    Session[ShoppingCart.CartSessionKey] = email;
        //}


        public ActionResult LogOn()
        {
            return View();
        }

        //[HttpPost]
        //public ActionResult LogOn(UserRegMst model, string returnUrl)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        if (Membership.ValidateUser(model.email, model.password))
        //        {
        //            FormsAuthentication.SetAuthCookie(model.email, model.RememberMe);
        //            if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
        //                && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
        //            {
        //                return Redirect(returnUrl);
        //            }
        //            else
        //            {
        //                return RedirectToAction("Index", "Home");
        //            }
        //        }
        //        else
        //        {
        //            ModelState.AddModelError("", "The user name or password provided is incorrect.");
        //        }
        //    }

            // If we got this far, something failed, redisplay form
        //    return View(model);
        //}

        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();

            return RedirectToAction("Index", "Home");
        }

        //public ActionResult Register()
        //{
        //    return View();
        //}

        //[HttpPost]
        //public ActionResult Register(UserRegMst model)
        //{
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            // Attempt to register the user
        //            db.UserRegMsts.Add(model);
        //            db.SaveChanges();

        //            return RedirectToAction("LogOn", "Account");
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        ModelState.AddModelError("", "ko tao dc!");
        //    }

        //    // If we got this far, something failed, redisplay form
        //    return View(model);
        //}
    }
}
